<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib prefix="pu" uri="/WEB-INF/tld/pageutil.tld"%>
<%@taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt-rt"%>
<%@taglib uri="http://java.sun.com/jstl/core_rt" prefix="c-rt"%>
<%@	page import="com.yaodian100.core.common.utils.ServerValue"%>
<c-rt:set var="midContextPath" value='<%=ServerValue.getMidContextPath()%>'/>
<c-rt:set var="order" value="${pu:get('com.yaodian100.ec.order.entity.Orders', applyClaim.orderId)}" /> 
<c-rt:set var="bank" value="${pu:get('com.yaodian100.ec.payment.entity.BankTransfer', applyClaim.bankTransferId)}" /> 
<script type="text/javascript">
function openOrderView() {
	  window.open("../order/popView.do?orderId=${applyClaim.orderId}", "order", "height=600, width=450,left=50, top=50, menubar=no, toolbar=no, location=yes, directories=no, status=yes,scrollbars=yes,resizable=yes");
}

	$().ready(function(){
		$("#dataNotMatchDialog").hide();
		
		$("#charge").click(function(){
			var doThis = true;
			if("${order.orderSt}" != "10"){
				doThis = confirm("此张订单非等待付款，你确定要继续？");
			}
			if(doThis == true){	
			$.getJSON("${midContextPath}/applyClaim/applyClaim!charge.do?type=json", 
					{applyClaimId : "${applyClaim.id}"}
				,function(claimStatusResult){
					if ( claimStatusResult == "90" )
						$("#applyClaimStatus").text("招领失败");
					else
						$("#applyClaimStatus").text("招领成功");
					alert("处理完成：" + $("#applyClaimStatus").text());
					location.href="${midContextPath}/applyClaim/view.do?applyClaimId=${applyClaim.id}";
			});
			}
		});
		$("#refund").click(function(){
			
			$.getJSON("${midContextPath}/applyClaim/applyClaim!refund.do?type=json", 
					{applyClaimId : "${applyClaim.id}"}
				,function(claimStatusResult){
					if ( claimStatusResult == "20" )
						$("#applyClaimStatus").text("退费处理中");
					else if (claimStatusResult == "60") 
						$("#applyClaimStatus").text("退款成功");
					else
						$("#applyClaimStatus").text("退费处理作业失败");
					alert("处理完成：" + $("#applyClaimStatus").text());
					location.href="${midContextPath}/applyClaim/view.do?applyClaimId=${applyClaim.id}";
			});
		});
		$("#dataNotMatch").click(function(){
			$("#dataNotMatchDialog").dialog({
				title:"${applyClaim.orderId} - 订单资料",
				modak:true,
				bgiframe: true,
				height: 200,
				width:500,
				modal: true
			});
			$("#saveReason").click(function(){
				if ( $("#claimReason").val() == "" ){
					alert("请填写退件原因");
					return false;
				}else{
					//储存资料
					document.UpdateReasonForm.submit();
					$("#dataNotMatchDialog").dialog('close');
				}
			});
			
			$("#cancleReason").click(function(){
				$("#dataNotMatchDialog").dialog('close');
			});
		});
	});
</script>
<table class="tb-data" width="100%">
	<tr><th colspan="6">招领单资料</th></tr>
	<tr>
		<th>招领单号</th>
		<td>${applyClaim.id}</td>
		<th>招领状态</th>
		<td id="applyClaimStatus">${claimStatusMenu.options[applyClaim.claimStatus].name}</td>
		<th>申请日期</th>
		<td><fmt-rt:formatDate value="${applyClaim.applyDate}" pattern="yyyy-MM-dd HH:mm:ss" /></td>
	</tr>
	<tr>
		<th>订单编号</th>
		<td><a href="javascript:openOrderView();" id="order">${applyClaim.orderId}</a></td>
		<th>订单状态</th>
		<td>${pu:menuOption('Order.status.md', order.orderSt).name}</td>
		<th>付款期限</th>
		<td><fmt-rt:formatDate value="${order.deadline}" pattern="yyyy-MM-dd HH:mm:ss" /></td>
	</tr>
	<tr>
		<th>汇款人</th>
		<td>${applyClaim.claimName }</td>
		<th>汇款银行</th>
		<td>${applyClaim.bankName }</td>
		<th>汇款时间</th>
		<td><fmt-rt:formatDate value="${applyClaim.expectDate}" pattern="yyyy-MM-dd HH:mm:ss" /></td>
	</tr>
	<tr>
		<th>电话</th>
		<td>${applyClaim.contactPhone}</td>
		<th>处理方式</th>
		<td colspan="3">${claimTypeMenu.options[applyClaim.claimType].name}</td>
	</tr>
	<tr>
		<th>订单应付金额</th>
		<td colspan="5"><fmt-rt:formatNumber value="${order.mustPay}" pattern="#,###,##0.00"/></td>
	</tr>
	<tr>
		<th>使用者输入汇款金额</th>
		<td colspan="5"><fmt-rt:formatNumber value="${applyClaim.claimAmount}" pattern="#,###,##0.00"/></td>
	</tr>
	<tr>
		<th>实际汇款金额</th>
		<td colspan="5"><fmt-rt:formatNumber value="${bank.amount}" pattern="#,###,##0.00"/></td>
	</tr>
	<tr>
		<th>地址</th>
		<td colspan="5">${applyClaim.contactAddress}</td>
	</tr>
	<tr>
		<th>汇款单资料</th>
		<td colspan="5">
		<table width="100%" border="1" cellspacing="0" cellpadding="0" class="tb-data">
  <tr>
    <td height="30" align=left><b>汇单编号：</b> ${bank.id} </td>
    <td align=left></td>
    <td align=left><b>状态：</b>${statusMenu.options[bank.status].name}<input type="hidden" name="bktId" value="${bank.id}" /></td>
    <td align=left><b>转入时间：</b>
    		<fmt-rt:formatDate pattern="yyyy/MM/dd HH:mm:ss" value="${bank.billDate}" /></td>
  </tr>
  <tr>
    <td height="30" align=left><b>汇款银行：</b>${bank.sourceBank}</td>
    <td align=left><b>汇款帐户：</b>${bank.sourceAccountNo}</td>
    <td align=left><b>帐户：</b>${bank.sourceAccountName}</td>
    <td align=left><b>金额：</b><font color="#ff3300">${bank.amount}</font></td>
  </tr>
  <tr>
    <td height="30" align=left><b>付款订单编号：</b><font color="#ff3300">${bank.orderId}</font></td>
    <td align=left><b>建档时间：</b><fmt-rt:formatDate pattern="yyyy-MM-dd HH:mm:ss" value="${bank.dataEntryDate}" /></td>
    <td align=left><b>建档人：</b>${bank.dataEntryMan}</td>
    <td align=left></td>
  </tr>
  <tr>
    <td height="30" colspan="5" valign="top" align=left><b>银行备注</b><BR>
　　${bank.bankMemo}</td>
  </tr>
  <tr>
    <td height="30" colspan="5" valign="top" align=left><b>内部备注</b><BR>
　　${bank.memo}</td>
  </tr>
</table>
		</td>
	</tr>
	<tr>
		<th>招领失败理由</th>
		<td colspan="5">${applyClaim.claimReason}</td>
	</tr>
	<tr>
		<th>招领资料图片</th>
		<td colspan="3"><img src="<%=ServerValue.getMidHostname()%>/claimImg/${applyClaim.id}${applyClaim.imgSubName}" height="150" width="250"/></td>
	</tr>
	<tr>
		<th>处理人员</th>
		<td colspan="5">${applyClaim.modifyUser}</td>
	</tr>
	<tr>
		<th>财务批准日期</th>
		<td colspan="3"><fmt-rt:formatDate pattern="yyyy-MM-dd" value="${applyClaim.reviewDate}"/></td>
	</tr>	
</table>
<p></p>
<div class="f-link"><a href="${midContextPath }/applyClaim/search.do">回查询页</a></div>
<c-rt:if test="${applyClaim.claimStatus == 10}">
	<div class="f-link"><a href="javascript:;" id="charge">订单收款</a></div>
	<div class="f-link"><a href="javascript:;" id="refund">退款至账户余额</a></div>
	<div class="f-link"><a href="javascript:;" id="dataNotMatch">资料不符,退件</a></div>
</c-rt:if>

<div id="dataNotMatchDialog" title="资料不符,退件" style="display:none;">
<form action="${midContextPath }/applyClaim/applyClaim!updateReason.do" name="UpdateReasonForm" method="post">
	<table class="tb-data" width="100%">
		<tr>
			<th>退件原因</th>
			<td><textarea rows="3" cols="60" id="claimReason" name="claimReason"></textarea></td>
		</tr>
	</table>
	<input type="hidden" name="applyClaimId" value="${applyClaim.id}"/>
	<input type="button" id="saveReason" name="saveReason" value="确认"/>
	<input type="button" id="cancleReason" name="cancleReason" value="取消"/>
</form>
</div>